package ar.com.temporis.manufacturing.domain;

import ar.com.temporis.framework.AbstractERPJTestCase;
import ar.com.temporis.framework.common.Observable;
import ar.com.temporis.framework.common.Observer;
import ar.com.temporis.system.domain.User;
import ar.com.temporis.system.persistence.UserRepository;


public class WorkOrderTestCase extends AbstractERPJTestCase {
	
	public void test() throws Exception {
		WorkOrder workOrder = new WorkOrder();
		
		Observer observer = new Observer() {
			@SuppressWarnings("static-access")
			public void update(Observable observable, Object state) {
				WorkOrderTestCase.this.assertEquals(WorkOrderState.CLOSED, state);
				WorkOrderTestCase.this.assertEquals(WorkOrderState.CLOSED, ((WorkOrder) observable).getWorkOrderState());
			}
		};
		
		workOrder.accept(observer);
		
		User user = (User) ((UserRepository) this.applicationContext.getBean("userRepository")).getAny();
		workOrder.closeTicket(user);
	}

}
